﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using BVCommon.Entities;
using BVClient.OrderItemServiceReference;
using BVClient.OrderServiceReference;
using BVClient.ProductServiceReference;

namespace BVClient.UserControls
{
    /// <summary>
    /// Interaction logic for FormControl.xaml
    /// </summary>
    public partial class FormControl : UserControl
    {
        public FormControl()
        {
            loadOrderItems();            
            InitializeComponent();
            tbxOrderCode.ItemsSource = OrderList;
            productComboBox.ItemsSource = ProductList;
            listOrder.ItemsSource = ProductList;
        }

        private IList<Order_Item> orderitemList = new List<Order_Item>();
        public IList<Order_Item> OrderItemList
        {
            get { return orderitemList; }
            private set { orderitemList = value; }
        }

        private void loadOrderItems()
        {
            using (OrderItemServiceClient client = new OrderItemServiceClient())
            {
                OrderItemList = client.GetData();
            }
        }

        private IList<Order> orderList = new List<Order>();
        public IList<Order> OrderList
        {            
            get 
            {
                using (OrderServiceClient client = new OrderServiceClient())
                {
                    orderList = client.GetData();
                }
                return orderList;
            }
            set { orderList = value; }
        }

        private IList<Product> productList = new List<Product>();
        public IList<Product> ProductList
        {
            get
            {
                using (ProductServiceClient client = new ProductServiceClient())
                {
                    productList = client.GetData();
                }
                return productList;
            }
            set { productList = value;}
        }
    }
}
